home *** CD-ROM | disk | FTP | other *** search
- /*
- * very important: for the atari keep this file 16/32 bit int clean
- * ++jrb
- */
-
- #ifndef NO_GNULIB3 /* skip entire file if NO_GNULIB3 */
-
- #ifdef atarist
- #include <stdlib.h>
- #endif
-
- /* Declare a pointer to void function type. */
-
- typedef void (*func_ptr) (void);
-
- /* Declare the set of symbols use as begin and end markers for the lists
- of global object constructors and global object destructors. */
-
- extern func_ptr __CTOR_LIST__[];
- extern func_ptr __DTOR_LIST__[];
-
- int atexit (void (*) (void));
- static void __do_global_dtors ();
- static void __do_global_ctors ();
-
- void
- __main ()
- {
- /* Support recursive calls to `main': run initializers just once. */
- static short initialized = 0;
- if (! initialized)
- {
- initialized = 1;
- __do_global_ctors ();
- }
- }
-
- /* Run all global constructors on entry to program, setup to run destructors
- at exit.
- */
- static void
- __do_global_ctors ()
- {
- func_ptr *p;
- for (p = __CTOR_LIST__ + 1; *p; )
- (*p++) ();
-
- atexit(__do_global_dtors);
- }
-
- /* Run all the global destructors on exit from the program. */
-
- static void
- __do_global_dtors ()
- {
- long nptrs = *(long *)__DTOR_LIST__;
- long i;
-
- /* Some systems place the number of pointers
- in the first word of the table.
- On other systems, that word is -1.
- In all cases, the table is null-terminated. */
-
- /* If the length is not recorded, count up to the null. */
- if (nptrs == -1)
- for (nptrs = 0; __DTOR_LIST__[nptrs + 1] != 0; nptrs++);
-
- /* GNU LD format. */
- for (i = nptrs; i >= 1; i--)
- __DTOR_LIST__[i] ();
- }
-
- #endif /* NO_GNULIB3 */
-